<!doctype html>
<html class="no-js">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>南京大学职业咨询室预约平台</title>
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <!-- No Baidu Siteapp-->
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='assets/i/ico_128X128.ico') }}">
    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">
    <link rel="icon" sizes="192x192" href="{{ url_for('static', filename='assets/i/app-icon72x72@2x.png') }}">
    <!-- Add to homescreen for Safari on iOS -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />

    <link rel="apple-touch-icon-precomposed" href="{{ url_for('static', filename='assets/i/app-icon72x72@2x.png') }}">
    <!-- Tile icon for Win8 (144x144 + tile color) -->
    <meta name="msapplication-TileImage" content="{{ url_for('static', filename='assets/i/app-icon72x72@2x.png') }}">
    <meta name="msapplication-TileColor" content="#0e90d2">
    <link rel="stylesheet" href="{{ url_for('static', filename='assets/css/amazeui.min.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='assets/css/app.css', v='1.4') }}">
    <script src="{{ url_for('static', filename='assets/js/jquery.min.js') }}"></script>
    <style>    
    .main {
        text-align: center;
    }
    
    #contact,
    #password {
        height: 35px;
        width: 180px;
        border: none;
    }
    
    .item {
        color: blue;
        background-color: #E93EFF;
        height: 30px;
        width: 50px;
    }

    .hismsg {
        text-align: center;
        color: gray;
        margin: 0;
        padding: 0;
        height: 5px;
    }

    </style>
</head>

<body>
<div class="admin-header">
    <!--<div class="header-back" onclick="history.back()">返回</div>-->
    <div class="header-title">教师管理台</div>
</div>
<div class="admin-content">
    <div class="alert alert-warning">
        {% with messages = get_flashed_messages() %}
          {% if messages %}
            <ul class=flashes>
            {% for message in messages %}
            <div class="am-alert am-alert-secondary" data-am-alert>
              <button type="button" class="am-close">&times;</button>
              <div style="text-align: center;">{{ message }}</div>
            </div>
            {% endfor %}
            </ul>
          {% endif %}
        {% endwith %}
    </div>
    <div class="Name" id="curtch" tcid="{{tcid}}">
        <njup>你好，{{ name }} 老师</njup>
    </div>

    {% for li in lists %}
    <div class="book-item-warp">
        <div class="book-item-title">
            <div class="fl"> <strong>预约序号：</strong>{{li['recid']}}</div>
        </div>
        <div class="book-item-line">
            <div class="fl"> <strong>学生姓名：</strong>{{ li['name'] }}</div>
            <div class="fr"> <strong>性别：</strong>{{ li['sex'] }}</div>
        </div>
        <div class="book-item-line">
            <div class="fl"> <strong>电话号码：</strong>{{li['contact']}}</div>
        </div>
        <div class="book-item-line">
            <div class="fl"> <strong>院系：</strong>{{li['department']}}&nbsp;{{li['major']}}&nbsp;{{li['grade']}}</div>
        </div>
        <div class="book-item-line">
            <div class="fl"> <strong>咨询内容：</strong>{{li['content']}}</div>
        </div>
        <div class="book-item-line">
            <div class="fl"> <strong>咨询日期：</strong>{{li['date']}}</div>
        </div>
        
        {% if li['demands'] %}
        <div class="book-item-line">
            <div class="fl"> <strong>需求：</strong>{{li['demands']}}</div>
        </div>
        {% endif %}
        
        {% if li['abstract'] %}
        <div class="book-item-line">
            <div class="fl"> <strong>摘要：</strong>{{li['abstract']}}</div>
        </div>
        {% endif %}
        
        <div class="book-item-line">
            <div class="fl"> <strong>咨询状态：</strong>{{li['status']}}</div>
        </div>

        <div class="book-item-line">
            <div class="fl"> <strong>反馈：</strong></div>{{li['feedback']}}
        </div>

        {% if li['readandwrite'] %}
        <div class="book-item-line">
         <textarea rows="5" class="input" type="text" name="fds" id="fd_{{li['recid']}}" style="width:100%;border:1px solid #e6e6e6;" placeholder="咨询完成时添加咨询反馈，取消预约则直接点击红色按钮" value="{{li['feedbackcp']}}"></textarea>
        </div>
        {% endif %}
        

        <div class="book-item-line">
            <div class="fr">
            {% if li['readandwrite'] %}
             <button value="{{li['recid']}}" onClick="teacher_add_fd(this.value,this)" class="am-btn am-btn-primary am-btn-sm">提交反馈</button>
            {% else %}
            {% endif %}
            </div>
            <div class="fl"> 
                {% if li['cancel'] %}
                <button value="{{li['recid']}}" tele="{{cont}}" onClick="teacher_cancel(this.value,this)" class="am-btn am-btn-danger am-btn-sm">取消预约</button>
                {% else %}
                {% endif %}
            </div>
        </div>
    </div>
     {% endfor %}

    <div class="am-cf">
        <button type="text" id="back_" value="返回" onclick="javascript:window.location.href='./get_teacher_center';" class="am-btn am-btn-default">返&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;回</button>
    </div>

    <form name="njusub">
        {{ form.csrf_token }}
    </form>
</div>

    
    <script type="text/javascript">

    /*function requestObject(){
        if (window.XMLHttpRequest)
            return new XMLHttpRequest();
        else if (window.ActiveXObject)
            return new ActiveXObject("Msxml2.XMLHTTP");
        else
            throw new Error("Error happend!");
    }*/

    function teacher_cancel(val,obj)
    {
        conf = window.confirm("确定取消？咨询开始前2小时内不予取消！");
        if (conf) {
            document.njusub.action="/get_teacher_cancel_page?cont="+$(obj).attr("tele")+"&yyseq="+val;
            document.njusub.method="post";
            document.njusub.submit();
        };
    }
    
    // 添加学生反馈信息，即使不填写也可以提交
    function teacher_add_fd(val, obj){
        conf = window.confirm("确定添加？只有咨询完成后才能填写反馈！");
        if (conf) {

            if ($("#fd_"+val).val()=="") {
                alert("请填写反馈内容！");
                return false;
            };

            var csrftoken = $('meta[name=csrf-token]').attr('content');
            $.ajaxSetup({
                beforeSend: function(xhr, settings) {
                    if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
                        xhr.setRequestHeader("X-CSRFToken", csrftoken)
                    }
                }
            });
            $.ajax({
                // 请求发送方式
                type: 'post',
                // 验证文件
                url: '/add_stu_feedback',
                // 用户输入的帐号密码
                data: {
                    feedback: $("#fd_"+val).val(),
                    recid: val
                },
                // 异步，不写默认为True
                async: 0,
                //请求成功后的回调
                success: function(data) {
                    alert(data.msg);
                    window.location.reload();
                },
                error: function() {
                    alert('服务端异常');
                }
            });
        };
    }

    </script>
</body>
</html>
